const projServ = require('../service/projServ.js')

const projCtrl = {
  // 总数
  deplistCount: async (ctx) => {
    const res  = await projServ.deplistCountServ()
    ctx.body = {
      code: 0,
      msg: 'success',
      data: res
    }
  },
  collectStatus: async (ctx) => {
    const params = ctx.request.body
    const res  = await projServ.collectStatusServ(params)
    ctx.body = {
      code: 0,
      msg: 'success',
      data: res
    }
  },
  //埋点浏览
  burryPoint: async (ctx) => {
    const params = ctx.request.body
    const res  = await projServ.burryPointServ(params)
    ctx.body = {
      code: 0,
      msg: 'success',
      data: res
    }
  },
  // 收藏项目
  collctProj: async (ctx) => {
    const params = ctx.request.body
    await projServ.collctProjServ(params)
    ctx.body = {
      code: 0,
      msg: 'success',
    }
  },
  // 删除收藏 
  deletCollet: async (ctx) => {
    const params = ctx.request.body
    await projServ.deletColletServ(params)
    ctx.body = {
      code: 0,
      msg: 'success',
    }
  },
  // 收藏列表
  collectList: async (ctx) => {
    const userId = ctx.query.userId
    const res = await projServ.collectListServ(userId)
    ctx.body = {
      code: 0,
      msg: 'success',
      data: res
    }
  },
  // 我发布的的用户列表
  myProjlist: async (ctx) => {
    const userId = ctx.query.userId
    const res = await projServ.myProjlistServ(userId)
    ctx.body = {
      code: 0,
      msg: 'success',
      data: res
    }
  },
  // 项目详情
  projDetail: async (ctx) => {
    const projId = ctx.query.projId
    const res = await projServ.projDetailServ(projId)

    // console.log(res);
    ctx.body = {
      code: 0,
      msg: 'success',
      data: res
    }
  },
  // 项目列表
  getprojList: async (ctx) => {
    const params = ctx.request.body
    const res = await projServ.getprojListServ(params)
    ctx.body = {
      code: 0,
      msg: 'success',
      data: res
    }
  },
  addproj: async (ctx) => {
    const params = ctx.request.body
    // console.log(params);
    await projServ.addprojServ(params)
    ctx.body = {
      code: 0,
      msg: 'success',
    }
  },
  deleteproj: async (ctx) => {
    const projId = ctx.request.body.projId
    await projServ.deleteprojServ(projId)
    ctx.body = {
      code: 0,
      msg: 'success',
    }
  }
}

module.exports = projCtrl